package cn.cocho.custom.yunCashierDf.utils;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

/**
 * 日志统一管理工具类
 * Created by shk on 14/11/15.
 */
@Service
public class LoggerUtils {

    Logger logger = Logger.getLogger(LoggerUtils.class);

    /**
     * 调试信息
     *
     * @param message 信息
     * @author KEQIAO KEJI
     */
    public void debug(Object message) {
        logger.info(getUserMessage() + message);
    }


    /**
     * 异常
     *
     * @param t 异常对象
     * @author KEQIAO KEJI
     */
    public void error(Throwable t) {
        error(getUserMessage(), t);
    }

    /**
     * 异常
     *
     * @param message 异常信息
     * @param t       异常对象
     * @author KEQIAO KEJI
     */
    public void error(Object message, Throwable t) {
        logger.error(getUserMessage() + message, t);
    }

    private String getUserMessage() {
        return "USER_ID:" + AppContexts.getUserId() + "\n";
    }

}
